﻿using B.S.Database.Domain.Entity;
using B.S.Database.ErrorCode;
using B.S.Database.Interface.Interface;
using B.S.Database.Read.Api.Application.Commands.Breeding;
using MediatR;

namespace B.S.Database.Read.Api.Application.CommandHandler.Breeding
{
    public class ImmuneShowCommandHandler : IRequestHandler<ImmuneShowCommands, Apiresult<List<Immune_Infomation>>>
    {
        private readonly IBaseResotity<Immune_Infomation> immuneRepo;

        public ImmuneShowCommandHandler(IBaseResotity<Immune_Infomation> ImmuneRepo)
        {
            immuneRepo = ImmuneRepo;
        }
        public Task<Apiresult<List<Immune_Infomation>>> Handle(ImmuneShowCommands request, CancellationToken cancellationToken)
        {
            Apiresult<List<Immune_Infomation>> res = new Apiresult<List<Immune_Infomation>>();
            res.Code = ApiEnums.成功;
            res.Message = ApiEnums.成功.ToString();
            var list = immuneRepo.GetAll().Where(c => c.TraceabilityId == request.TraceabilityId&&!c.IsDelete);
            res.Data = list.ToList();
            return Task.FromResult(res);
        }
    }
}
